<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateInvoiceSubjectsTable extends Migration
{

    const TABLE = \App\Models\Invoice\Subject::TABLE;

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        !Schema::hasTable(self::TABLE) &&
        Schema::create(self::TABLE, function (Blueprint $table) {
            $table->uuid('id')->primary();
            $table->string('name', 50)->default('');
            $table->uuid('parking_lot_id')->default('');
            $table->string('type', 50)->default('');
            $table->string('type_cn', 50)->default('');
            $table->json('parameters')->nullable();
            $table->unique(['parking_lot_id', 'type'], 'uni_idx_subject');
            $table->boolean('enabled')->default(false);
            $table->string('remark')->default('');
            $table->timestamps();
        });
        DB::statement("alter table `".self::TABLE."` comment '开票主体';");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists(self::TABLE);
    }
}
